package com.yyl.rbacs.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.yyl.rbacs.annotation.DataFilter;
import com.yyl.rbacs.sys.entity.SysDept;
import com.yyl.rbacs.sys.mapper.SysDeptMapper;
import com.yyl.rbacs.sys.service.ISysDeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yyl.rbacs.utils.Constants;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 部门管理 服务实现类
 * </p>
 *
 * @author YuanSir
 * @since 2022-10-28
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
    
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    @DataFilter(dataField = "dept_id")
    public List<SysDept> queryDeptByMap(Map<String, String> params) {
    
        String sql = params.get(Constants.DATA_FILTER);
    
        return list(new QueryWrapper<SysDept>().apply(StringUtils.isNotBlank(sql), sql));
    }
}
